<html>
<head><meta charset="utf-8"><title>Is there any relation of incremental compilation and CGUs? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Is.20there.20any.20relation.20of.20incremental.20compilation.20and.20CGUs.3F.html">Is there any relation of incremental compilation and CGUs?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="227463788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Is%20there%20any%20relation%20of%20incremental%20compilation%20and%20CGUs%3F/near/227463788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Is.20there.20any.20relation.20of.20incremental.20compilation.20and.20CGUs.3F.html#227463788">(Feb 23 2021 at 16:52)</a>:</h4>
<p>During a training, someone asked if incremental compilation occurs at the granularity of codegen units. I don't know the answer to that, but my guess would be that the two are orthogonal.</p>



<a name="227463914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Is%20there%20any%20relation%20of%20incremental%20compilation%20and%20CGUs%3F/near/227463914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Is.20there.20any.20relation.20of.20incremental.20compilation.20and.20CGUs.3F.html#227463914">(Feb 23 2021 at 16:53)</a>:</h4>
<p>they are pretty related <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/monomorphize/partitioning/index.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/monomorphize/partitioning/index.html</a></p>



<a name="227464078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Is%20there%20any%20relation%20of%20incremental%20compilation%20and%20CGUs%3F/near/227464078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Is.20there.20any.20relation.20of.20incremental.20compilation.20and.20CGUs.3F.html#227464078">(Feb 23 2021 at 16:54)</a>:</h4>
<p>incremental before LLVM is very granular, but during codegen it's only as granular as a CGU</p>



<a name="227464225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Is%20there%20any%20relation%20of%20incremental%20compilation%20and%20CGUs%3F/near/227464225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Is.20there.20any.20relation.20of.20incremental.20compilation.20and.20CGUs.3F.html#227464225">(Feb 23 2021 at 16:55)</a>:</h4>
<p>So in debug, we default to CGU=256; does that mean that the granularity of incremental (and thus the effectiveness)  is increased?</p>



<a name="227464309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Is%20there%20any%20relation%20of%20incremental%20compilation%20and%20CGUs%3F/near/227464309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Is.20there.20any.20relation.20of.20incremental.20compilation.20and.20CGUs.3F.html#227464309">(Feb 23 2021 at 16:55)</a>:</h4>
<p>I think so</p>



<a name="227464318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Is%20there%20any%20relation%20of%20incremental%20compilation%20and%20CGUs%3F/near/227464318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Is.20there.20any.20relation.20of.20incremental.20compilation.20and.20CGUs.3F.html#227464318">(Feb 23 2021 at 16:55)</a>:</h4>
<blockquote>
<p>From that point of view it would make sense to maximize the number of codegen units by,</p>
</blockquote>



<a name="227464398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Is%20there%20any%20relation%20of%20incremental%20compilation%20and%20CGUs%3F/near/227464398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Is.20there.20any.20relation.20of.20incremental.20compilation.20and.20CGUs.3F.html#227464398">(Feb 23 2021 at 16:56)</a>:</h4>
<blockquote>
<p>The bigger the codegen units, the better LLVM's optimizer can do its work, but also the smaller the compilation time reduction we get from incremental compilation.</p>
</blockquote>



<a name="227464412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Is%20there%20any%20relation%20of%20incremental%20compilation%20and%20CGUs%3F/near/227464412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Is.20there.20any.20relation.20of.20incremental.20compilation.20and.20CGUs.3F.html#227464412">(Feb 23 2021 at 16:56)</a>:</h4>
<p>Note that making the amount of codegen units too high increases overhead inside LLVM and the linker, negating any benefits of increasing the amount of codegen units.</p>



<a name="227464481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Is%20there%20any%20relation%20of%20incremental%20compilation%20and%20CGUs%3F/near/227464481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Is.20there.20any.20relation.20of.20incremental.20compilation.20and.20CGUs.3F.html#227464481">(Feb 23 2021 at 16:56)</a>:</h4>
<p>Makes sense. I think the part I was missing was that incremental extends beyond "just rustc" (but in retrospect it must)</p>



<a name="227464581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Is%20there%20any%20relation%20of%20incremental%20compilation%20and%20CGUs%3F/near/227464581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Is.20there.20any.20relation.20of.20incremental.20compilation.20and.20CGUs.3F.html#227464581">(Feb 23 2021 at 16:57)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> which is why it's 256 and not 9999999999, I guess?</p>



<a name="227464688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Is%20there%20any%20relation%20of%20incremental%20compilation%20and%20CGUs%3F/near/227464688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Is.20there.20any.20relation.20of.20incremental.20compilation.20and.20CGUs.3F.html#227464688">(Feb 23 2021 at 16:57)</a>:</h4>
<p>I believe so. Let me find the PR that added the 256 cgu cap.</p>



<a name="227465336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Is%20there%20any%20relation%20of%20incremental%20compilation%20and%20CGUs%3F/near/227465336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Is.20there.20any.20relation.20of.20incremental.20compilation.20and.20CGUs.3F.html#227465336">(Feb 23 2021 at 17:01)</a>:</h4>
<p>That is <a href="https://github.com/rust-lang/rust/issues/70156">#70156</a>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>